import { getUserInfo } from '../service/user';
import Storage from './storage';

const async = {
  async userinfo({ syncParams, resolve, reject }) {
    const { token } = syncParams;
    if (!token) return;
    const data = await getUserInfo(token);
    if (data.code === 0) {
      Storage.save('user', data.data);
      resolve && resolve(data.data);
    } else {
      reject && reject(new Error(data.msg));
    }
  }
};



export default async;